﻿@using QDT.Common
@using QDT.Core
@using QDT.Core.Members
@using QDT.Core.Projects
@using QDT.MVC
@model QDT.Core.Projects.Project
@{
    ViewBag.Title = "标的详情";
    User user = QDTContext.Current.User;
}   

@section Head
{
    <script type="text/javascript" src="@Url.Content("~/Content/Default/JS/vendor/modernizr-2.8.0.min.js")"> </script>
    <script type="text/javascript" src="@Url.Content("~/Content/Default/JS/vendor/raphael.2.1.0.min.js")"> </script>
    <script type="text/javascript" src="@Url.Content("~/Content/Default/JS/vendor/justgage.1.0.1.min.js")"> </script>
}

<div class="ui-body">
    <div class="ui-inner">

        <div class="ui-box fn-clear">
            
            <div class="ui-box-mian">
                <div class="ui-box-hd">
                    <h1 class="ui-box-title">@Model.Name</h1>
                    <p>
                        <span class="ui-badge ui-badge-gray">企业项目</span>
                        @if (Model.TypeID == 2)
                        {
                            <span class="ui-badge ui-badge-orange" title="资产抵押">押</span>
                        }
                        @if (Model.TypeID == 3 || Model.TypeID == 9 || Model.TypeID == 10)
                        {
                            <span class="ui-badge ui-badge-green" title="机构担保">保</span>
                        }
                    </p>
                </div>
                <table class="ui-project-detail">
                    <tr>
                        <td class="title">借款金额：</td>
                        <td style="color: #f39c12;">@Model.BorrowAmount.ToMoney()</td>
                        <td class="title">年化收益：</td>
                        <td>@Model.Rate.ToString("0.00")<span>%</span></td>
                    </tr>
                    <tr>
                        <td class="title">借款期限：</td>
                        <td>@Model.RepayTime<span>个月</span></td>
                        <td class="title">还款方式：</td>
                        <td>付息还本</td>
                    </tr>
                    <tr>
                        <td class="title">总借款额：</td>
                        <td>@(string.IsNullOrWhiteSpace(Model.Parent.TotalBorrow) ? "-" : Model.Parent.TotalBorrow)</td>
                        <td class="title">借款用途：</td>
                        <td>@(string.IsNullOrWhiteSpace(Model.Parent.LoanPurpose) ? "-" : Model.Parent.LoanPurpose)</td>
                    </tr>
                    <tr>
                        <td class="title">保障方式：</td>
                        <td>
                            <i class="iconfont" style="color: #27ae60;" title="以资产抵押方式提供100%本息保障">&#xf0030;</i><span>&nbsp;@Model.Parent.Warrant</span>
                        </td>
                        <td class="title">保障范围：</td>
                        <td>本金+利息</td>
                    </tr>
                    <tr>
                        <td class="title">项目描述：</td>
                        <td class="colspan" colspan="3">@Model.Parent.Description.ToHtml()</td>
                    </tr>
                </table>
            </div>

            <div class="ui-box-side">
                <div id="project_progress" class="ui-project-rate"></div>
                <div class="ui-project-pay">
                    <dl class="fn-clear">
                        <dt>可投金额：</dt>
                        <dd class="big">@Model.NeedMoney.ToMoney()</dd>
                    </dl>
                    
                    <dl class="fn-clear">
                        <dt>可用余额：</dt>
                        <dd class="big">
                            @user.UserAccount.Money.ToMoney()
                            @if (user.GroupID != 1)
                            {
                                <a href="@Url.Action("MoneyIncharge", "User")" style="font-size: 14px;">充值</a>
                            }
                        </dd>
                    </dl>

                    <div id="bid_form" class="hide">
@*                        <form action="@Url.Action("Bid", "Project")" method="POST">*@
@*                            <p>*@
@*                                <input type="hidden" name="ID" value="@Model.ID"/>*@
@*                                <input class="ui-input ui-input-large" name="money" type="text"/>*@
@*                                <input type="password" class="ui-input ui-input-large" name="safePassword" value=""/>*@
@*                            </p>*@
@*                            <p>*@
@*                                <button type="submit" class="ui-btn-big">投资</button>*@
@*                            </p>*@
@*                        </form>*@
                    </div>

                </div>
            </div>
        </div>
        
        <div class="ui-box fn-clear">
            @Html.Action("CompanyInfo", "Project", new { projectId = Model.ID })
            @Html.Action("OtherFile", "Project", new { projectId = Model.ID })
        </div>
        
        

        @Html.Action("BorrowerSta", "Project", new { userId = Model.UserID })

        <div class="ui-grid-row">
            <div class="ui-grid-11">
                @if (Model.Status == ProjectStatus.Repaying || Model.Status == ProjectStatus.Repaid)
                {
                    if (!Model.Rate.Equals(0.4))
                    {
                        @Html.Action("RepayList", "Project", new { projectid = Model.ID })
                    }
                }
                else
                {
                    <div class="ui-box">
                        <div class="ui-box-hd">
                            <h3 class="ui-box-title">还款模型</h3>
                        </div>
                        <div class="ui-table-container">
                            <table class="ui-table ui-table-noborder">
                                <thead>
                                    <tr>
                                        <th>预期还款时间</th>
                                        <th>类型</th>
                                        <th>还款金额(元)</th>
                                        <th class="text-right">状态</th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                }
            </div>
            
            <div id="project_bid_list">
                @Html.Action("BidList", "Project", new { projectid = Model.ID })
            </div>

        </div>

    </div>
</div>

    
<script type="text/javascript">
    $("#project_progress").ready(function() {
        var progress = new JustGage({
            id: "project_progress",
            value: @Model.Progress.ToString("0.0"),
            min: 0,
            max: 100,
            title: "@(Model.Progress >= 100 ? "融资成功" : "投资进度")",
            label: "",
            showInnerShadow: false,
            levelColors: [
                "#2ecc71",
                "#f1c40f",
                "#e74c3c"
            ],
            gaugeWidthScale: 1
        });
    });
    
    $('#more_bid_list').click(function() {
        $("#project_bid_list").load("/Project/AllBidList?projectid=" + @Model.ID);
    });
        
</script>

@*
<script type="text/javascript">
    var s = {};
    s.product = "@Model.ID";
    //产品ID - 示例 - s.product="020003003";
    s.userid = "@QDTContext.Current.User.ID";
// 注册用户ID - 示例 - s.userid="100123ab";
</script>
<script type="text/javascript">
    try {
        var idgTracker = _alysP.init("ifc", "T-000067-01");
        idgTracker._setTrackPath(idgJsHost + '://idigger.allyes.com/main/adftrack');
        idgTracker._setECM(s);
        idgTracker._trackPoint();
    } catch(err) {
    }
</script>
*@